const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const ArticleSchema = new Schema({
    created: {
        type: Date,
        default:Date.now
    },
    title: {
        type: String,
        default: '',
        trim: true,
    },
    content: {
        type: String,
        default: '',
        trim: true
    },
    creator: {
        type: Schema.Types.ObjectId,
        ref: 'User'
    },
    comments:[{
        content: String,
        publisher: {
            type: Schema.Types.ObjectId,
            ref: 'User'
        },
        created: {
            type: Date,
            default: Date.now
        }
    }]
});

mongoose.model('Article', ArticleSchema);

